import jdk.jshell.spi.ExecutionControl;

import java.util.*;

public class Test {
    public static void main1(String[] args) {
        int[] arr={12,31,6,32,10,9,60,10,4,12,8,5,6};
        int[] arr2={25,84,21,47,15,27,68,35,20};
        System.out.println(Arrays.toString(arr2));
        //TestSort.SelectSort2(arr);
        //TestSort.BubbleSort(arr);
        //TestSort.quickSort(arr);
        //TestSort.mergeSort(arr);
        //TestSort.mergeSortNor(arr);
        TestSort.quickSort(arr2);
        System.out.println(Arrays.toString(arr2));
    }
    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set=new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            set.add(jewels.charAt(i));
        }
        int count=0;
        for (int i = 0; i < stones.length(); i++) {
            if(set.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }
    public List<String> topKFrequent(String[] words, int k) {
        HashMap<String,Integer> map=new HashMap<>();
        for(String word:words){
            if(map.get(word)==null){
                map.put(word,1);
            }else {
                int val=map.get(word);
                map.put(word,val+1);
            }
        }
        PriorityQueue<Map.Entry<String,Integer>> minHeap=new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue())==0){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        for(Map.Entry<String,Integer> entry:map.entrySet()){
            if(minHeap.size()<k){
                minHeap.offer(entry);
            }else {
                Map.Entry<String,Integer> top=minHeap.peek();
                if(top.getValue().compareTo(entry.getValue())<0){
                    minHeap.poll();
                    minHeap.offer(entry);
                } else if (top.getValue().compareTo(entry.getValue())==0) {
                    if(top.getKey().compareTo(entry.getKey())>0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
        ArrayList<String> list=new ArrayList<>();
        for (int i = 0; i < k; i++) {
            Map.Entry<String,Integer> tmp=minHeap.poll();
            list.add(tmp.getKey());
        }
        Collections.reverse(list);
        return list;
    }
    public static void BrokenKey(String str1,String str2){
        str1=str1.toUpperCase();
        str2=str2.toUpperCase();
        HashSet<Character> set = new HashSet<>();
        HashSet<Character> set2 = new HashSet<>();
        for (int i = 0; i < str2.length(); i++) {
            set.add(str2.charAt(i));
        }
        for (int i = 0; i < str1.length(); i++) {
            char ch=str1.charAt(i);
            if(!set.contains(ch)&&!set2.contains(ch)){
                set2.add(ch);
                System.out.println(ch);
            }
        }
    }

    public static void main3(String[] args) {
        String str1="7_This_is_a_test";
        String str2="_hs_s_a_es";
        BrokenKey(str1,str2);
    }
    public static boolean containsNearbyDuplicate(int[] nums, int k) {
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if(map.containsKey(nums[i])&&i-map.get(nums[i])<=k){
                return true;
            }else {
                map.put(nums[i],i);
            }
        }
        return false;
    }

    public static void main4(String[] args) {
        int[] arr={1,2,3,1,2,3};
        System.out.println(containsNearbyDuplicate(arr,2));
    }

    public static void main(String[] args) {
        int[] arr={19,14,23,1,68,20,84,27,55,11,10,79};
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]%7+" ");
        }
    }
}
